package com.sip.stream.rxbus;

import android.util.Log;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public final class Utils {
    private Utils() {
        throw new UnsupportedOperationException("u can't instantiate me...");
    }

    public static boolean equals(Object obj, Object obj2) {
        return obj == obj2 || (obj != null && obj.equals(obj2));
    }

    public static void requireNonNull(Object... objArr) {
        if (objArr == null) {
            Log.w("RxBus", "requireNonNull objects");
            throw null;
        }
        for (Object obj : objArr) {
            if (obj == null) {
                Log.w("RxBus", "requireNonNull object");
                throw null;
            }
        }
    }

    public static <T> Class<T> getTypeClassFromParadigm(RxBus.Callback<T> callback) {
        Type genericSuperclass;
        if (callback == null) {
            return null;
        }
        Type[] genericInterfaces = callback.getClass().getGenericInterfaces();
        if (genericInterfaces.length == 1) {
            genericSuperclass = genericInterfaces[0];
        } else {
            genericSuperclass = callback.getClass().getGenericSuperclass();
        }
        Type type = ((ParameterizedType) genericSuperclass).getActualTypeArguments()[0];
        while (type instanceof ParameterizedType) {
            type = ((ParameterizedType) type).getRawType();
        }
        String obj = type.toString();
        if (obj.startsWith("class ")) {
            obj = obj.substring(6);
        } else if (obj.startsWith("interface ")) {
            obj = obj.substring(10);
        }
        try {
            return (Class<T>) Class.forName(obj);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
            return null;
        }
    }

    public static Class getClassFromObject(Object obj) {
        String obj2;
        if (obj == null) {
            return null;
        }
        Class<?> cls = obj.getClass();
        if (cls.isAnonymousClass() || cls.isSynthetic()) {
            Type[] genericInterfaces = cls.getGenericInterfaces();
            if (genericInterfaces.length == 1) {
                Type type = genericInterfaces[0];
                while (type instanceof ParameterizedType) {
                    type = ((ParameterizedType) type).getRawType();
                }
                obj2 = type.toString();
            } else {
                Type genericSuperclass = cls.getGenericSuperclass();
                while (genericSuperclass instanceof ParameterizedType) {
                    genericSuperclass = ((ParameterizedType) genericSuperclass).getRawType();
                }
                obj2 = genericSuperclass.toString();
            }
            if (obj2.startsWith("class ")) {
                obj2 = obj2.substring(6);
            } else if (obj2.startsWith("interface ")) {
                obj2 = obj2.substring(10);
            }
            try {
                return Class.forName(obj2);
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        }
        return cls;
    }

    public static void logW(String str) {
        Log.w("RxBus", str);
    }

    public static void logE(String str) {
        Log.e("RxBus", str);
    }
}
